package com.smallA.utils;

public class JavaUtils {

    private final static String TYPE_STRING = "String";
    private final static String TYPE_INT = "int";
    private final static String TYPE_DOUBLE = "double";
    private final static String TYPE_FLOAT = "float";
    private final static String TYPE_CHAR = "char";
    private final static String TYPE_BOOL = "boolean";
    private final static String TYPE_DEFINITION = "未定义类型";


    /**
     * 判断数据类型用
     *
     * @param obj 要判断的数据类型
     * @return 返回判断结果
     */
    public static String typeof(Object obj) {
        if (obj instanceof String) {
            return TYPE_STRING;
        }
        if (obj instanceof Integer) {
            return TYPE_INT;
        }
        if (obj instanceof Double) {
            return TYPE_DOUBLE;
        }
        if (obj instanceof Character) {
            return TYPE_CHAR;
        }
        if (obj instanceof Boolean) {
            return TYPE_BOOL;
        }
        if (obj instanceof Float) {
            return TYPE_FLOAT;
        }
        return TYPE_DEFINITION;
    }
}
